home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
filesyst
/
dosfs
/
dmsdosfs.000
/
dmsdosfs
/
dmsdosfs-0.6.9b
/
dmsdos_fs.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-29
|
13KB
|
346 lines
#ifndef _LINUX_DMSDOS_FS_H
#define _LINUX_DMSDOS_FS_H
/*
* The DMSDOS filesystem constants/structures
*/
#include <linux/autoconf.h>
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/fd.h>
#define DMSDOS_VERSION 0x00000609
#define DMSDOS_LT "b"
#define DMSDOS_LOWEST_COMPATIBLE_VERSION 0x00000608
/* MAXFRAGMENT value:
Increase this value if you get a 'CVF too fragmented, not mounted' message.
To find out an appropriate value, run SCANDISK /FRAGMENT under DOS on the
CVF dmsdos refuses to mount. It is recommended to use a slightly larger
number here just in case you want to enlarge the CVF under DOS later.
See documentation for details.
Note: For usualy msdos systems 10 should be sufficient; win95 seems to
need 20, with DriveSp 3 it may require 50 or higher. */
#define MAXFRAGMENT 50
#define USE_VMALLOC
/* this is for safety: always wait until the fs access that came first
is finished before the next one is processed - undef this for speed
improvement - but it may cause problems in strange cases... */
#undef SERIALIZE_RW_ACCESS
/* known compression methods */
#define DS_0_0 0x00005344
#define DS_0_1 0x01005344
#define DS_0_2 0x02005344
#define JM_0_0 0x00004D4A
/* drivespace 3 high compression */
#define JM_0_1 0x01004D4A
/* drivespace 3 ultra compression */
#define SQ_0_0 0x00005153
/* other defines for options */
#define READ_ONLY -1
#define UNCOMPRESSED -2
#define GUESS -3
typedef struct
{ long sector_minus_1;
short size_lo_minus_1;
short size_hi_minus_1;
short unknown; /* some bits I don't know to handle.... */
short flags; /* 00...0uc - u=used, c=compressed */
} Mdfat_entry;
#define LISTSIZE 16384 /* must be a power of 2 */
/* flag values */
#define D_EMPTY 0
#define D_VALID 1 /* entry is valid -> cluster to be compressed */
#define D_IN_D_ACTION 2 /* is being compressed by daemon */
#define D_OVERWRITTEN 3 /* has been overwritten by dmsdos while daemon
is compressing it -> throw away the result from
the daemon */
typedef struct
{ int clusternr;
char cvfnr;
int length; /* in bytes */
char flag;
int method;
} Rwlist;
#ifdef __KERNEL__
#ifdef USE_VMALLOC
#include<linux/mm.h>
#define MALLOC(x) vmalloc(x)
#define FREE(x) vfree(x)
#else
#include<linux/malloc.h>
#define MALLOC(x) kmalloc(x,GFP_KERNEL)
#define FREE(x) kfree(x)
#endif
#ifdef SERIALIZE_RW_ACCESS
#define LOCK_READWRITE lock_readwrite()
#define UNLOCK_READWRITE unlock_readwrite()
#else
#define LOCK_READWRITE
#define UNLOCK_READWRITE
#endif
/* number of cvfs that can be handled at the same time */
/* the following number *must* stay below 31 */
#define MAXDBLFILES 10
/* cache sizes -- please note that the sum of these three are the number
of fs buffers dmsdos *permanently* uses - keep small on systems that
are short on memory */
#define MDFATCACHESIZE 40
#define DFATCACHESIZE 20
#define BITFATCACHESIZE 10
/* defines which inode bits are 'misused' for the cvfnr*/
/* adapted for new 2 GB support */
#define DMSDOS_CVFNR_BITS 26
#define DMSDOS_ORIGINO_MASK 0x3ffffff
#define DMSDOS_MAX_DOS_SECTPERCLUST 64
/* defines for MDFAT entry */
/* adapted for new 2 GB support (grrr... supposed and guessed, may be wrong) */
/* was 0x1fffff before, reverse it if the new value causes problems */
#define DBLSECTOR_MASK 0x3fffff
extern int dmsdos_lookup(struct inode *dir,const char *name,int len,
struct inode **result);
extern int dmsdos_create(struct inode *dir,const char *name,int len,int mode,
struct inode **result);
extern int dmsdos_mkdir(struct inode *dir,const char *name,int len,int mode);
extern int dmsdos_rmdir(struct inode *dir,const char *name,int len);
extern int dmsdos_unlink(struct inode *dir,const char *name,int len);
extern int dmsdos_rename(struct inode *old_dir,const char *old_name,int old_len,
struct inode *new_dir,const char *new_name,int new_len
#ifdef __FOR_KERNEL_2_0_1
, int must_be_dir
#endif
);
extern void dmsdos_put_inode(struct inode *inode);
extern void dmsdos_put_super(struct super_block *sb);
extern struct super_block *dmsdos_read_super(struct super_block *s,
void *data,int);
#ifdef __FOR_KERNEL_1_3
extern void dmsdos_statfs(struct super_block *sb,struct statfs *buf,int);
#else
extern void dmsdos_statfs(struct super_block *sb,struct statfs *buf);
#endif
extern int dmsdos_bmap(struct inode *inode,int block);
extern void dmsdos_read_inode(struct inode *inode);
extern void dmsdos_write_inode(struct inode *inode);
extern int dmsdos_notify_change(struct inode *,struct iattr *);
extern struct inode_operations dmsdos_dir_inode_operations;
extern int dmsdos_readdir (struct inode *inode, struct file *filp,
#ifdef __FOR_KERNEL_1_3
void *dirent, filldir_t);
#else
struct dirent *dirent, int count);
#endif
extern struct inode_operations dmsdos_file_inode_operations;
extern struct inode_operations dmsdos_file_inode_operations_1024;
extern int dmsdos_file_read(struct inode *, struct file *, char *, int);
extern int dmsdos_file_write(struct inode *, struct file *,
#ifdef __FOR_KERNEL_1_3
const
#endif
char *, int);
extern struct inode_operations dmsdos_file_inode_operations_no_bmap;
extern void dmsdos_truncate(struct inode *inode);
extern int dmsdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
#endif
/* this must be known outside the kernel too */
typedef struct {
int s_dcluster;/*[45-46]*/
int s_mdfatstart;/*[36-37]+1*/
int s_fatstart;/*[39-40]+[14-15]*/
int s_rootdir;/*[41-42]+[39-40]*/
int s_rootdiranzentry;
int s_sectperclust;
int s_first[MAXFRAGMENT];
int s_anzahl[MAXFRAGMENT];
int s_16bitfat;
int s_datastart;
int s_dataend;
int s_comp;
int s_bootblock;/*[39-40]*/
int s_cfaktor;
int s_full;
int s_max_cluster;
int s_max_cluster2;
int s_support_lfn;
} Dblsb;
#ifdef __KERNEL__
typedef struct {
struct buffer_head * a_buffer;
unsigned int a_area;
unsigned long a_time;
unsigned int a_cvfnr;
unsigned int a_acc;
} Acache;
struct buffer_head* read_dbl_sector(struct super_block*,
int dblsector,int cvfnr);
struct buffer_head* noread_dbl_sector(struct super_block*,
int dblsector,int cvfnr);
void bh_free(struct super_block*, struct buffer_head*);
void bh_dirty(struct super_block*, struct buffer_head*);
void dbl_mdfat_value(struct super_block*,int clusternr,int cvfnr,
Mdfat_entry*new,Mdfat_entry*mde);
int dbl_fat_nextcluster(struct super_block*,int clusternr,int cvfnr,int*);
int dbl_bitfat_value(struct super_block*,int sektornr,int cvfnr,int*);
int dbltest(struct inode* inode);
int dostest(struct inode* inode);
int dbl_init(struct super_block* sb, void* datai, int,int,int,int,int,int);
int dmsdos_readdirx(struct inode *inode,struct file *filp,
#ifdef __FOR_KERNEL_1_3
void *dirent,filldir_t filldir);
#else
struct dirent *dirent,int count);
#endif
int dmsdos_file_readx(
struct inode *inode,
struct file *filp,
char *buf,
int count);
void dmsdos_read_inodex(struct inode *inode);
int dmsdos_lookupx(struct inode *dir,const char *name,int len,
struct inode **result);
int dmsdos_read_cluster(struct super_block*,
unsigned char*clusterd, int clusternr,int cvfnr);
void exit_dbl(struct super_block*sb);
void free_chain(struct super_block*sb, int clusternr, int cvfnr);
int find_free_bitfat(struct super_block*sb, int sektornr,int cvfnr, int size);
int allocate_cluster(struct super_block*sb, int cvfnr);
int allocate_first_cluster(struct super_block*sb, int cvfnr);
int allocate_next_cluster(struct super_block*sb, int akt_cluster, int cvfnr);
int replace_existing_cluster(struct super_block*sb, int cluster,
int near_sector,
Mdfat_entry*, int cvfnr);
int allocate_first_dir_cluster(struct super_block*sb,int cvfnr);
int allocate_next_dir_cluster(struct super_block*sb, int akt_cluster,
int cvfnr);
int scan_dbl_dir_4_empty(struct super_block*sb, int dirstartclust, int cvfnr);
int scan_dbl_dir_4_n_empty(struct super_block*sb, int dirstartclust, int cvfnr,
int n, int*lfn_inos);
#endif /*__KERNEL__*/
int compress(unsigned char* clusterk, unsigned char* clusterd,
int size, int method,int);
#ifdef __KERNEL__
int dmsdos_write_cluster(struct super_block*sb,
unsigned char* clusterd, int length, int clusternr,
int near_sector, int cvfnr, int ucflag);
int dmsdos_file_writex(struct inode *inode, struct file *filp,
#ifdef __FOR_KERNEL_1_3
const
#endif
char *buf, int count);
void dmsdos_truncatex(struct inode *inode);
void dmsdos_put_inodex(struct inode *inode);
void dmsdos_write_inodex(struct inode *inode);
int dmsdos_notify_changex(struct inode * inode,struct iattr * attr);
int dmsdos_createx(struct inode *dir,const char *name,int len,int mode,
struct inode **result);
int dmsdos_mkdirx(struct inode *dir,const char *name,int len,int mode);
int dmsdos_rmdirx(struct inode *dir,const char *name,int len);
int dmsdos_unlinkx(struct inode *dir,const char *name,int len);
int dmsdos_unlink_umsdos(struct inode *dir,const char *name,int len);
int dmsdos_renamex(struct inode *old_dir,const char *old_name,int old_len,
struct inode *new_dir,const char *new_name,int new_len
#ifdef __FOR_KERNEL_2_0_1
, int must_be_dir
#endif
);
#define CHS(i) ( (unsigned short)i[0]|(unsigned short)i[1]<<8 )
#endif /*__KERNEL__*/
#define CHL(i) ( (unsigned long)i[0]|(unsigned long)i[1]<<8| \
(unsigned long)i[2]<<16|(unsigned long)i[3]<<24 )
#ifdef __KERNEL__
struct buffer_head* read_real_sector(struct super_block* sb,int sector);
struct buffer_head* noread_real_sector(struct super_block* sb,int sector);
int dbl_mdfat_cluster2sector(struct super_block*sb,int clusternr,int cvfnr);
int read_dbl_direntry(struct super_block*sb,
int dbl_clusterno,int cvfnr,int entrynr,
unsigned char*buf);
int dmsdos_get_entry(struct inode *dir, loff_t *pos,unsigned char * buf);
int dmsdos_parent_ino(struct inode*dir);
int scan_dbl_dir_4_filename(struct super_block*sb, int dirstartclust,
unsigned const char*tofind,int len,
int cvfnr);
int dmsdos_ioctl_dir(struct inode*dir, struct file*filp, unsigned int cmd,
unsigned long data);
int read_lfn_direntry(struct super_block*sb,int dirstartclust,int cvfnr,
int entrynr, char*longname, unsigned char*buf,
int*lfn_inos);
int scan_dbl_dir_4_lfn(struct super_block*sb, int dirstartclust,
const char*tofind,int len,int cvfnr,int*lfn_inos);
int dmsdos_get_lfn_entry(struct inode *dir, loff_t *pos,unsigned char * buf,
char*longname);
int remove_lfn_entry(struct super_block*sb, int dirstartclust,
const char*tofind, int len, int cvfnr);
int create_lfn_entry(struct super_block*sb, int dirstartclust,
const char*longname, int len, int cvfnr);
int fixdir(struct super_block * sb, int cvfnr);
int simple_check(struct super_block*sb, int cvfnr);
int init_dmsdos_fs(void);
int try_daemon(int clusternr, int cvfnr, int length, int method);
void clear_list_cvfnr(int cvfnr);
void clear_list(void);
int moveback(struct super_block*sb, int clusternr, int cvfnr);
void lock_readwrite(void);
void unlock_readwrite(void);
#endif /* __KERNEL__ */
/* defines for external dmsdos utilities */
/* ioctl_dir commands, write is only allowed by root, read_block too */
#define DMSDOS_IOCTL_MIN 0x2000
#define DMSDOS_IOCTL_MAX 0x201F
#define DMSDOS_GET_DBLSB 0x2000
#define DMSDOS_EXTRA_STATFS 0x2001
#define DMSDOS_READ_BLOCK 0x2002
#define DMSDOS_WRITE_BLOCK 0x2003
#define DMSDOS_READ_DIRENTRY 0x2004
#define DMSDOS_WRITE_DIRENTRY 0x2005
#define DMSDOS_READ_BITFAT 0x2006
#define DMSDOS_WRITE_BITFAT 0x2007
#define DMSDOS_READ_MDFAT 0x2008
#define DMSDOS_WRITE_MDFAT 0x2009
#define DMSDOS_READ_DFAT 0x200a
#define DMSDOS_WRITE_DFAT 0x200b
#define DMSDOS_SET_COMP 0x200c
#define DMSDOS_SET_CF 0x200d
#define DMSDOS_SIMPLE_CHECK 0x200e
#define DMSDOS_DUMPCACHE 0x200f
#define DMSDOS_D_ASK 0x2010
#define DMSDOS_D_READ 0x2011
#define DMSDOS_D_WRITE 0x2012
#define DMSDOS_D_EXIT 0x2013
#define DMSDOS_MOVEBACK 0x2014
#define DMSDOS_SET_MAXCLUSTER 0x2015
#define IS_DMSDOS_IOCTL(cmd) ((cmd)>=DMSDOS_IOCTL_MIN&&(cmd)<=DMSDOS_IOCTL_MAX)
#endif